(function ($) {
    if(window.authLoadedFlag) {
        return;
    }
    $(function() {
        //$("#header .swagger-ui-wrap").css("max-width", '100%');
        var tokenTxt = $("<input id='input_apiKey' type='text'/>" +
            "<button id='btnSetToken' type='button'>设置token</button>");
        $("#auth_container").append(tokenTxt);
        $("#auth_container").on(
            "click","#btnSetToken",
            function(e) {
                e.preventDefault();
                console.log($("#input_apiKey").val());
                if($("#input_apiKey").val() == "") {
                    alert("请输入token;");
                    return false;
                }
                window.swaggerUi.api.clientAuthorizations.add("Authorization",
                    new SwaggerClient.ApiKeyAuthorization("Authorization", "Bearer " + $("#input_apiKey").val(), "header"));
                alert("设置成功!");
                return false;
            });

        $("#swagger-ui-container").on("click", ".submit", function () {
            if($(this).parents("#TokenAuth_ApiTokenAuthAuthenticatePost").length) {

            }
        });
    });
    window.authLoadedFlag = true;
})(jQuery);